package org.gaaidou.ptarmigan.springboot.data.jpa.datasource;

import org.springframework.util.Assert;

final class RouteStrategyHolder {
    private static final ThreadLocal<String> routingDataSourceHolder = new ThreadLocal<>();

    static void use(String strategy) {
        Assert.notNull(strategy, "strategy must not null");
        routingDataSourceHolder.set(strategy);
    }

    static String current() {
        return routingDataSourceHolder.get();
    }

    static void clear() {
        routingDataSourceHolder.remove();
    }
}

